<route lang="json5" type="page">
{
  layout: 'default',
  style: {
    navigationBarTitleText: '地图',
  },
}
</route>

<template>
  <map
    id="map"
    class="map"
    :latitude="dimension"
    :longitude="longitude"
    :markers="covers"
    @regionchange="regionchange"
  ></map>
</template>

<script setup>
const dimension = ref('')

const longitude = ref('')

const covers = ref([])
const controls = ref(null)
const storeName = ref('')
const address = ref('')

const regionchange = async () => {}

const navigateToDestination = () => {
  uni.openLocation({
    latitude: parseFloat(dimension.value),
    longitude: parseFloat(longitude.value),
    name: storeName.value,
    address: address.value,
    success: () => console.log('导航成功'),
    fail: (err) => console.error('导航失败', err),
  })
}

onLoad((option) => {
  dimension.value = option.dimension
  longitude.value = option.longitude
  storeName.value = option.storeName
  address.value = option.address
})

onReady(() => {
  navigateToDestination()
})
</script>

<style lang="scss" scoped>
.map {
  width: 750rpx;
  height: 100vh;
}
</style>
